@import '../bootstrap'
@import '../theme'

/* Theme */
toolbar($material)
  background-color: $material.app-bar
  color: $material.text.primary

  .btn:not(.btn--disabled)
    color: $material.text.primary

theme(toolbar, "toolbar")

.toolbar
  position: relative
  transition: .3s $transition.swing
  height: 100%
  will-change: padding-top
  elevation(4)

  .input-group--solo
    .input-group__details
      display: none

  .input-group--single-line:not(.input-group--solo)
    padding: 0

    label
      top: auto

/** Children */
.toolbar
  &__title
    font-size: $headings.h6.size
    font-weight: $headings.h6.weight
    letter-spacing: $headings.h6.letter-spacing
    margin: 16px 8px 0 8px;
    white-space: nowrap
    overflow: hidden
    text-overflow: ellipsis
    vertical-align: middle
    text-align: center

  &__content, &__extension
    display: flex
    flex-direction: row
    align-items: center

    > .list
      flex: 1 1 auto
      margin: 0 !important // come back to this
      max-width: 100%

    > .btn:last-child, > .menu:first-child
      margin-bottom: 8px

    > .btn:first-child, > .menu:first-child
      margin-top: 8px

    > *:not(.btn):not(.toolbar__title):not(.menu):last-child
      margin-bottom: $grid-gutters.lg

    > *:not(.btn):not(.toolbar__title):not(.menu):first-child
      margin-top: $grid-gutters.lg

  &__content
    width: $toolbar-height

  &__extension
    width: $toolbar-extension-height

  &__items
    display: flex
    justify-content: flex-start
    flex-direction: row
    width: 100%
    max-height: 100%
    padding: 0

    .menu
      width: 100%

    > .menu .menu__activator
      width: 100%

      .btn
        width: 100%
        margin: 0

    > .btn
      width: 100%
      margin: 0

  @media $display-breakpoints.xs-only
    .toolbar__content,
    .toolbar__extension
      > .btn:last-child
        margin-bottom: 17px

      > .btn:first-child
        margin-bottom: 17px

      > *:not(.btn):last-child
        margin-bottom: $grid-gutters.xl

      > *:not(.btn):first-child
        margin-top: $grid-gutters.xl

  @media all and (max-height: $grid-breakpoints.sm) and (orientation: portrait)
    toolbar-content(7px)

    &__content,
    &__extension
      width: $toolbar-mobile-portrait-height

  @media all and (max-height: $grid-breakpoints.sm) and (orientation: landscape)
    &__content,
    &__extension
      width: $toolbar-mobile-landscape-height


/** Types */
.toolbar
  &--card
    border-radius: $card-border-radius $card-border-radius 0 0
    elevation(0)

  &--fixed
    position: fixed
    z-index: 2

  &--fixed, &--absolute
    top: 0
    left: 0

  &--absolute
    position: absolute
    z-index 2

    + main
      padding-right: 0

  &--fixed
    + main
      padding-right: $toolbar-height

    @media all and (max-height: $grid-breakpoints.sm) and (orientation: portrait)
      + main
        padding-right: $toolbar-mobile-portrait-height

    @media all and (max-height: $grid-breakpoints.sm) and (orientation: landscape)
      + main
        padding-right: $toolbar-mobile-landscape-height

    &.toolbar--extended
      + main
        padding-right: $toolbar-width + $toolbar-extension-height

      &.toolbar--dense
        + main
          padding-right: $toolbar-mobile-landscape-height * 2

      &.toolbar--prominent
        + main
          padding-right: $toolbar-height * 2

      @media all and (max-height: $grid-breakpoints.lg) and (orientation: landscape)
        + main
          padding-right: $toolbar-mobile-landscape-height * 2

    &.toolbar--dense
      + main
        padding-right: $toolbar-mobile-landscape-height

    &.toolbar--prominent
      + main
        padding-right: $toolbar-height


  &--floating
    display: inline-flex
    margin: 16px
    height: auto

  &--prominent
    .toolbar__content
      width: $toolbar-height

    .toolbar__extension
      width: $toolbar-height

    toolbar-content(15px)

  &--dense
    .toolbar__content,
    .toolbar__extension
      width: $toolbar-mobile-landscape-height

    toolbar-content(7px)

.toolbar__extension
  .toolbar__title
    margin-top: 72px !important

  .tabs__bar
    align-self: flex-end
    margin: 0

toolbar-content(left)
  .toolbar__content,
  .toolbar__extension
    > *:first-child
      margin-top: left

    > *:last-child
      margin-bottom: left
